package thread.zjitc.net.lib.syanchronized;

/**
 * @author 朱志文
 * @data 2019/11/16 0016
 */
public class MySysnchroizedThread {
    int count=0;
    public void chese(int choice) {
        switch (choice){
            case 1:
                work();
                break;
            case 2:
                work2();
                break;
                default:
                    break;
        }
    }

    private void work2() {
        System.out.println("运行线程Name2：" + Thread.currentThread().getName());
        System.out.println("结束线程Name2：" + Thread.currentThread().getName());
    }

    private synchronized void work() {
        System.out.println("运行线程Name：" + Thread.currentThread().getName());
        System.out.println("结束线程Name：" + Thread.currentThread().getName());
    }
    public void getcount(){
        System.out.println(count);
    }
    public void increae(){
        for (int i = 0; i <5000 ; i++) {
            count++;
            System.out.println(Thread.currentThread().getName()+","+count);
        }
    }
}
